//
//  AppDelegate.m
//  FreightAssistant
//
//  Created by leo on 15/10/27.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "AppDelegate.h"

#import "KKExchangeRateManager.h"
#import "KKDataBaseManager.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //  启动数据库
    [KKDataBaseManager defaultManager];
    
    //  启动汇率数据
    [KKExchangeRateManager defaultManager];
    
    
    if (0) {
        
        [self loadingCommoditysData];
        [self loadingCustomerData];
    }

    return YES;
}

#pragma mark - 

/**
 *  加载商品测试数据
 */
- (void)loadingCommoditysData {
    
    KKDataBaseManager *dataBaseManager = [KKDataBaseManager defaultManager];
    
    NSString *commodity1 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CommodityInfo withRecords: @{@"name":@"苹果",@"purchasePrice":@"8",@"price":@"15",@"inventory":@"100",@"capacity":@"1",@"sales":@"0"} sqlIdentifier : nil];
    
    NSString *commodity2 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CommodityInfo withRecords: @{@"name":@"香蕉",@"purchasePrice":@"8",@"price":@"15",@"inventory":@"100",@"capacity":@"1",@"sales":@"0"} sqlIdentifier : nil];
    
    NSString *commodity3 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CommodityInfo withRecords: @{@"name":@"葡萄",@"purchasePrice":@"8",@"price":@"15",@"inventory":@"100",@"capacity":@"1",@"sales":@"0"} sqlIdentifier : nil];
    
    NSString *commodity4 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CommodityInfo withRecords: @{@"name":@"哈密瓜",@"purchasePrice":@"8",@"price":@"15",@"inventory":@"100",@"capacity":@"1",@"sales":@"0"} sqlIdentifier : nil];
    
    NSString *commodity5 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CommodityInfo withRecords: @{@"name":@"火龙果",@"purchasePrice":@"8",@"price":@"15",@"inventory":@"100",@"capacity":@"1",@"sales":@"0"} sqlIdentifier : nil];
    
    [dataBaseManager execInsertTransactionSQLStringArray: @[commodity1,commodity2,commodity3,commodity4,commodity5]];
}

/**
 *  加载客户测试数据
 */
- (void)loadingCustomerData {
    
    KKDataBaseManager *dataBaseManager = [KKDataBaseManager defaultManager];
    
    NSString *sqlString1 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CustomerInfo withRecords: @{@"name":@"张三",@"phone":@"123456789",@"address":@"110"} sqlIdentifier: nil];
    
    NSString *sqlString2 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CustomerInfo withRecords: @{@"name":@"李四",@"phone":@"234567891",@"address":@"110"} sqlIdentifier: nil];
    
    NSString *sqlString3 = [dataBaseManager sqlStringOfInsertRecordIntoTableName:KKDataBase_TableName_CustomerInfo withRecords: @{@"name":@"王五",@"phone":@"345678912",@"address":@"110"} sqlIdentifier: nil];
    
    [dataBaseManager execInsertTransactionSQLStringArray: @[sqlString1,sqlString2,sqlString3]];
}


@end
